import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../controllers/chat_controller.dart';
import 'message_bubble.dart';

class ChatMessages extends GetView<ChatController> {
  const ChatMessages({super.key});

  @override
  Widget build(BuildContext context) {
    return Obx(
      () => ListView.builder(
        padding: const EdgeInsets.all(16),
        reverse: true,
        itemCount: controller.messages.length,
        itemBuilder: (context, index) {
          final message = controller.messages[controller.messages.length - 1 - index];
          return MessageBubble(message: message);
        },
      ),
    );
  }
}